package com.waves.netty.nio;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 基于非阻塞IO的数据excel导出
 * @author dlw
 */
public class ExcelNioTestMain {
    public static void main(String[] args) throws ClassNotFoundException, IOException {
        List<List<User>> list = new ArrayList();
        for (int i = 0; i < 1000000; i++) {
            List<User> dataList = new ArrayList();
            User user = User.builder()
                    .name("张" + i)
                    .age(i)
                    .sex("男")
                    .city("苏州")
                    .country("China")
                    .address("新区")
                    .build();
            dataList.add(user);
            list.add(dataList);
        }

        long startTime = System.currentTimeMillis();
        String excelName = "非阻塞IO数据导出.xlsx";
        //excel导出的头部，需要在实体中加上@FieldName注解。例如：@FieldName(columnName = "姓名")
        ExcelNioExporter excelExporter = new ExcelNioExporter(list, excelName, User.class);
        excelExporter.export();
        long endTime = System.currentTimeMillis();
        System.out.println("NIO导出 程序运行时间：" + (endTime - startTime) + " 毫秒");
    }
}
